package com.fengchunge.util;

import java.util.regex.Pattern;

/**
 * @author: tianmingtai
 * @create: 2021/02/26 16:05
 * @description:
 */

public class RegexUtils {

    private static String CHECK_EMAIL = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";

    public static boolean isEmail(String email) {
        if (null == email || "".equals(email)) {
            return false;
        }
        return Pattern.matches(CHECK_EMAIL, email);

    }

    public static boolean isPhoneNumber(String mobile) {
        if (null == mobile || "".equals(mobile)) {
            return false;
        }
        String regex = "(\\+\\d+)?1[34578]\\d{9}$";
        return Pattern.matches(regex, mobile);
    }

    public static void main(String[] args) {
        String msg = "1dasd23424@qq.cmn";
        String ph = "1598884455";
        System.out.println(isEmail(msg));
        System.out.println(isPhoneNumber(ph));

    }


}
